﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Abp.Auditing;
using Abp.Authorization;
using Abp.Authorization.Users;
using Abp.Notifications;
using Abp.Organizations;
using AutoMapper;
using pandx.Mulan.Auditing.Dto;
using pandx.Mulan.Authorization.Permissions.Dto;
using pandx.Mulan.Authorization.Roles;
using pandx.Mulan.Authorization.Roles.Dto;
using pandx.Mulan.Authorization.Users;
using pandx.Mulan.Authorization.Users.Dto;
using pandx.Mulan.Authorization.Users.Importing.Dto;
using pandx.Mulan.Authorization.Users.Profile.Dto;
using pandx.Mulan.Books;
using pandx.Mulan.Books.Dto;
using pandx.Mulan.Dictionaries;
using pandx.Mulan.Dictionaries.Dto;
using pandx.Mulan.Flow.FlowInstances.Dto;
using pandx.Mulan.Flow.FlowSchemes.Dto;
using pandx.Mulan.Flows;
using pandx.Mulan.Form.FormSchemes.Dto;
using pandx.Mulan.Forms;
using pandx.Mulan.OrganizationUnits.Dto;

namespace pandx.Mulan
{
    public static class CustomDtoMapper
    {
        public static void CreateMappings(IMapperConfigurationExpression configuration)
        {
            //User
            configuration.CreateMap<User, UserEditDto>()
                .ForMember(dto => dto.Password, options => options.Ignore())
                .ReverseMap()
                .ForMember(user => user.Password, options => options.Ignore());
            configuration.CreateMap<User, UserListDto>();
            configuration.CreateMap<CurrentUserProfileEditDto, User>().ReverseMap();
            configuration.CreateMap<UserLoginAttemptDto, UserLoginAttempt>().ReverseMap();
            configuration.CreateMap<User, OrganizationUnitUserListDto>().ForMember(dto=>dto.OrganizationUnits,options=>options.Ignore());
            configuration.CreateMap<ImportUserDto, User>();

            //Role
            configuration.CreateMap<UserRole, UserListRoleDto>();
            configuration.CreateMap<Role, RoleListDto>();
            configuration.CreateMap<Role, OrganizationUnitRoleListDto>();
            configuration.CreateMap<Role,RoleEditDto>().ReverseMap();
            configuration.CreateMap<User, RoleUserDto>();
            
            //OrganizationUnit
            configuration.CreateMap<OrganizationUnit, OrganizationUnitDto>();
            configuration.CreateMap<OrganizationUnit, UserListOrganizationUnitDto>().ReverseMap();

            //Permission
            configuration.CreateMap<Permission, FlatPermissionDto>();
            configuration.CreateMap<Permission, FlatPermissionWithLevelDto>();

            //Flow
            configuration.CreateMap<FlowInstance, FlowInstanceListDto>();
            configuration.CreateMap<FlowScheme, FlowSchemeListDto>();
            configuration.CreateMap<FlowInstance, FlowInstanceEditDto>().ReverseMap();
            configuration.CreateMap<FlowScheme, FlowSchemeEditDto>().ReverseMap();
            configuration.CreateMap<CreateOrUpdateFlowInstanceInput, AllotInput>();
            configuration.CreateMap<VerifyNodeInput, AllotInput>();
            configuration.CreateMap<FlowOperationHistory, FlowOperationHistoryListDto>();
            
            //AuditLog
            configuration.CreateMap<AuditLog, AuditLogListDto>();

            //DictionaryCategory
            configuration.CreateMap<DictionaryCategory, DictionaryCategoryListDto>();
            configuration.CreateMap<DictionaryCategory, DictionaryCategoryEditDto>().ReverseMap();
            
            //Dictionary
            configuration.CreateMap<Dictionary, DictionaryListDto>();
            configuration.CreateMap<Dictionary, DictionaryEditDto>().ReverseMap();
            
            //Book
            configuration.CreateMap<Book, BookListDto>();
            configuration.CreateMap<Book, BookEditDto>().ReverseMap();
            
            //Form
            configuration.CreateMap<FormScheme, FormSchemeListDto>();
            configuration.CreateMap<FormScheme, FormSchemeEditDto>().ReverseMap();
            
            //Notification
            configuration.CreateMap<UserNotificationInfo, UserNotificationInfo>();
            configuration.CreateMap<TenantNotificationInfo, TenantNotification>();

        }
    }
}

